package com.ruoyi.web.controller.qsng;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.qsng.domain.KTalentRecruitment;
import com.ruoyi.qsng.service.IKTalentRecruitmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 人才招聘Controller
 *
 * @author kanglou
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/qsng/recruitment")
@Api(tags = "pc--人才招聘Controller")
public class KTalentRecruitmentController extends BaseController {
    @Autowired
    private IKTalentRecruitmentService kTalentRecruitmentService;

    /**
     * 查询人才招聘列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:recruitment:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询人才招聘列表")
    public TableDataInfo list(KTalentRecruitment kTalentRecruitment) {
        startPage();
        List<KTalentRecruitment> list = kTalentRecruitmentService.selectKTalentRecruitmentList(kTalentRecruitment);
        return getDataTable(list);
    }

    /**
     * 导出人才招聘列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:recruitment:export')")
    @Log(title = "人才招聘", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出人才招聘列表")
    public void export(HttpServletResponse response, KTalentRecruitment kTalentRecruitment) {
        List<KTalentRecruitment> list = kTalentRecruitmentService.selectKTalentRecruitmentList(kTalentRecruitment);
        ExcelUtil<KTalentRecruitment> util = new ExcelUtil<KTalentRecruitment>(KTalentRecruitment.class);
        util.exportExcel(response, list, "人才招聘数据");
    }

    /**
     * 获取人才招聘详细信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:recruitment:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取人才招聘详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(kTalentRecruitmentService.selectKTalentRecruitmentById(id));
    }

    /**
     * 新增人才招聘
     */
    @PreAuthorize("@ss.hasPermi('qsng:recruitment:add')")
    @Log(title = "人才招聘", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增人才招聘")
    public AjaxResult add(@RequestBody KTalentRecruitment kTalentRecruitment) {
        return toAjax(kTalentRecruitmentService.insertKTalentRecruitment(kTalentRecruitment));
    }

    /**
     * 修改人才招聘
     */
    @PreAuthorize("@ss.hasPermi('qsng:recruitment:edit')")
    @Log(title = "人才招聘", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改人才招聘")
    public AjaxResult edit(@RequestBody KTalentRecruitment kTalentRecruitment) {
        return toAjax(kTalentRecruitmentService.updateKTalentRecruitment(kTalentRecruitment));
    }

    /**
     * 删除人才招聘
     */
    @PreAuthorize("@ss.hasPermi('qsng:recruitment:remove')")
    @Log(title = "人才招聘", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除人才招聘")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(kTalentRecruitmentService.deleteKTalentRecruitmentByIds(ids));
    }
}
